<template>
  <div class="add-box">
    <h3>项目信息</h3>
    <el-form
      :label-position="labelPosition"
      label-width="80px"
      :model="formLabelAlign"
      :rules="rules"
      ref="ruleForm1"
    >
      <el-row>
        <el-col span="8">
          <el-form-item label="名称" prop="name">
            <el-input v-model="formLabelAlign.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col span="8">
          <el-form-item label="活动区域" prop="region">
            <el-input v-model="formLabelAlign.region"></el-input>
          </el-form-item>
        </el-col>
        <el-col span="8">
          <el-form-item label="活动形式" prop="type">
            <el-input v-model="formLabelAlign.type"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!--            
            <el-row>
                <el-col span="8">
                     <el-form-item label="名称">
                        <el-input v-model="formLabelAlign.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col span="8">
                     <el-form-item label="活动区域">
                        <el-input v-model="formLabelAlign.region"></el-input>
                    </el-form-item>
                </el-col>
               <el-col span="8">
                     <el-form-item label="活动形式">
                        <el-input v-model="formLabelAlign.type"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
             <el-row>
                <el-col span="8">
                     <el-form-item label="名称">
                        <el-input v-model="formLabelAlign.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col span="8">
                     <el-form-item label="活动区域">
                        <el-input v-model="formLabelAlign.region"></el-input>
                    </el-form-item>
                </el-col>
               <el-col span="8">
                     <el-form-item label="活动形式">
                        <el-input v-model="formLabelAlign.type"></el-input>
                    </el-form-item>
                </el-col>
            </el-row> -->
    </el-form>

    <div>
      <el-button>取消</el-button>
      <el-button type="primary" @click="confirmSubmit()">确认</el-button>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      id: "",
      labelPosition: "right",
      formLabelAlign: {
        name: "",
        region: "",
        type: "",
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "blur" },
        ],
        type: [
          { required: true, message: "请选择活动类型", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    //接收url传过来的参数
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
      alert(this.id);
    }
  },
  mounted() {
    this.getGoodsInfo();
  },
  methods: {
    //获取商品信息后，将返回的数据赋值给你的表单
    getGoodsInfo() {
    //   let self = this;

    //   self.formLabelAlign = {
    //     name: "李四",
    //     region: "胜多负少的",
    //     type: "师德师风打多少分",
    //   };
      //   axios.post('http://szjfweb.zhjt.top:38003/sjfapi/project/queryPage1111', this.formLabelAlign)
      //     .then(function (response) {
      //         console.log(response);
      //         self.formLabelAlign = {
      //             name: '李四',
      //             region: '胜多负少的',
      //             type: '师德师风打多少分'
      //         }
      //     })
      //     .catch(function (error) {
      //         console.log(error);
      //     });
    },
    //保存
    confirmSubmit() {
      console.log(this.formLabelAlign);

      this.$refs['ruleForm1'].validate((valid) => {
            //验证成功
            if (valid) {
                alert('submit!');
                axios
                    .post(
                    "http://szjfweb.zhjt.top:38003/sjfapi/project/save",
                    this.formLabelAlign
                    )
                    .then(function (response) {
                    console.log(response);
                    })
                    .catch(function (error) {
                    console.log(error);
                    });
                            
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });



    },
  },
};
</script>

<style lang="less" scoped>
.add-box {
  h3 {
    text-align: left;
    padding-left: 20px;
  }
}
</style>